﻿using System;
using Util;

namespace IterationLife.Extensions.Extensions
{
    public static class DateTimeExtension
    {
        public static DateTime? ToDateTime(this long? time)
        {
            if (time == null)
                return null;
            return ToDateTime(time.SafeValue());
        }

        public static DateTime ToDateTime(this long time)
        {
            DateTime start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime date = start.AddMilliseconds(time).ToLocalTime();
            return date;
        }
    }
}
